import matplotlib.pyplot as plt
import numpy as np

y1 = [151.32, 148.54, 138.72, 122.45, 119.12, 122.23, 137.53, 128.02, 124.71]
y2 = [268.75, 255.32, 248.98, 224.31, 204.77, 151.36, 140.23, 130.74, 126.25]
y3 = [298.78, 269.35, 249.71, 240.53, 234.16, 175.31, 152.84, 150.25, 143.42]
y4 = [317.23, 300.09, 289.28, 282.37, 253.43, 220.19, 183.24, 161.47, 149.88]

res = [y1, y2, y3, y4]
res = np.array(res)
res = np.mean(res, axis=0)

yerr1 = []
yerr2 = []
yerr3 = []
yerr4 = []
l = 9
for i in range(l):
    yerr1.append((y1[i] - res[i]))
    yerr2.append((y2[i] - res[i]))
    yerr3.append((y3[i] - res[i]))
    yerr4.append((y4[i] - res[i]))

# print(yerr1)
# print(yerr2)
# print(yerr3)
# print(yerr4)

x = [0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8]
y = res

plt.subplot(221)
plt.xticks([0.4, 0.5, 0.6, 0.7, 0.8])
plt.yticks([100, 150, 200, 250, 300, 350])
plt.errorbar(x, y, fmt="bo-", yerr=yerr1, lolims=[False, False, False, False, False, False, False, False, False],
             uplims=[True, True, True, True, True, True, True, True, True])
plt.legend(['LDC-COR'], loc='upper right')

plt.subplot(222)
plt.errorbar(x, y, fmt="go--", yerr=yerr2, uplims=[False, False, False, False, False, True, True, True, True],
             lolims=[True, True, True, True, True, False, False, False, False])
plt.legend(['LDC-OR'], loc='upper right')

plt.subplot(223)
plt.errorbar(x, y, fmt="ro--", yerr=yerr3, uplims=[False, False, False, False, False, False, True, False, False],
             lolims=[True, True, True, True, True, True, False, True, True])
plt.legend(['LDC-ACOR'], loc='upper right')

plt.subplot(224)
plt.errorbar(x, y, fmt="ko--", yerr=yerr4, uplims=[False, False, False, False, False, False, False, False, False],
             lolims=[True, True, True, True, True, True, True, True, True])
plt.legend(['LDC-AOR'], loc='upper right')

plt.tight_layout()
plt.show()
